/*
	THIS FILE IS A PART OF RDR 2 SCRIPT HOOK SDK
				http://dev-c.com
			(C) Alexander Blade 2019

	  THIS FILE WAS MODIFIED BY SRGAMERIO
			   https://gitloft.com
*/

#include "script.h"
#include "scriptmenu.h"
#include "keyboard.h"

#include <unordered_map>
#include <vector>
#include <string>
#include <ctime>

using namespace std;

#include "scriptinfo.h"

void kidnap_with_a_coach() {

	int task_sequence(47847);
	const int ARR_SIZE_rsrctnpc = 1024;
	Ped peds[ARR_SIZE_rsrctnpc];
	Ped playerPed = PLAYER::PLAYER_ID();
	int pedCount_rsrctnpc = worldGetAllPeds(peds, ARR_SIZE_rsrctnpc);

	for (int i = 0; i < pedCount_rsrctnpc; i++) {
			if (PED::IS_PED_HUMAN(peds[i]) && PLAYER::IS_PLAYER_FREE_AIMING_AT_ENTITY(PLAYER::PLAYER_ID(), peds[i])) {
				if (IsKeyJustUp(VK_F3)) {
					AI::CLEAR_PED_TASKS(peds[i],0,0);
					AI::CLEAR_PED_SECONDARY_TASK(peds[i]);
					AI::OPEN_SEQUENCE_TASK(&task_sequence);
					AI::TASK_ENTER_VEHICLE(peds[i], PLAYER::GET_PLAYERS_LAST_VEHICLE(), -1, 2, 1.0f, 0, 0);
					AI::CLOSE_SEQUENCE_TASK(task_sequence);
					PED::SET_PED_SEEING_RANGE(peds[i], 0.0);
					AI::TASK_PERFORM_SEQUENCE(peds[i], task_sequence);
					AI::CLEAR_SEQUENCE_TASK(&task_sequence);
				}
		}
	}
}

void main()
{
	while (true)
	{
		kidnap_with_a_coach();
		WAIT(0);
	}
}

void ScriptMain()
{
	srand(GetTickCount64());
	main();
}
